//定义
function Person(name,age){
    this.name = name;
    this.age = age;
    this.info = function (){
        console.log("info() 方法")
    }
}

var p = new Person('yeeku',30);
for(let propName in p){
    // 属性名
    console.log("对象属性名:" + propName + ",属性值:" + p[propName]);
}

class TypeOfValue{
    static UNDEFINED = "undefined";
}

// 判断当前类型的
class TypeOfValueUtils{
    static isUndefined(value){
        return (typeof value) == "undefined";
    }

    static isFunction(value){
        return (typeof value) == "function";
    }

    static isInteger(value){
        // 下面是第1种方法判断
        // return (typeof value === 'number') && ( value % 1 === 0);
        return Number.isInteger(value);
    }

    static isNumber(value){
        return (typeof value) == "number";
    }

    static isObject(value){
        return (typeof value) == "object";
    }
}


function test1(){
    console.log("test1()");
    let s;
    console.log(TypeOfValueUtils.isUndefined(s));
    s = "2";
    console.log(TypeOfValueUtils.isUndefined(s));

    function call(){
        console.log("call()");
    }
    console.log(TypeOfValueUtils.isFunction(call));


    function genFunctionArray(size){
        console.log(typeof size);
        const arr = [];
        for(let i = 0; i < size;i++){
            arr.push(function (){
               console.log("execute() i:" + i);
            });
        }
        return arr;
    }

    const result = genFunctionArray(2);
    console.log(result.length);

    const result2 = genFunctionArray("af");
    console.log(result2.length);

    console.log(TypeOfValueUtils.isInteger(2.2));
    console.log(TypeOfValueUtils.isInteger(2));

    const result3 = undefined;
    console.log(new String(undefined));

    console.log(new String(undefined) == 'undefined');
    console.log(new String(undefined) == 'undefined');

    // 箭头函数
    const caller = ()=>{
        console.log("caller")
    }
    console.log("判断 caller()");
    console.log(TypeOfValueUtils.isFunction(caller));
}
test1();


function test22(){
    // 在页面上
    // let userAgent = navigator.userAgent;
    let s = new String(undefined);
    // console.log(userAgent);
    console.log(s.toString());

    // Object.name
    console.log(Object.name);

}

test22();

